angular.module('meMoreOpinionaireControllers', [])

  .controller('meMoreOpinionaireCtrl', function ($scope, $state,$timeout,Toast,Loading, Storage, MoreOpinionaire, ENV) {

    $scope.isShow = false;
    var memberId = Storage.get("member").member_id;

    $scope.advice = {
      member_id: memberId,
      af_content: "",
      af_state: "未处理"
    };

    //提交意见反馈内容
    $scope.submitOpinion = function () {
      //验证输入内容
      console.log($scope.advice);
      if($scope.advice.af_content == ""){
        Toast.showMessage("反馈内容不能为空");
        /*$ionicLoading.show({
          noBackdrop: true,
          template: '反馈内容不能为空',
          duration: 1500
        });*/
      }else{
        MoreOpinionaire.addOpinion($scope.advice);
      }
    };

    $scope.$on('Me.addOpinion', function () {
      var result = MoreOpinionaire.getAddOpinionJson();
      $scope.isShow = true;
      $scope.advice.af_content = "";
      $scope.sendMsg = result.sendMsg;
      $timeout(function () {
        $scope.isShow = false;
      }, 2000);
    });

  });
